package com.example.kliven.because.adapter;

import android.content.Context;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

import com.example.kliven.because.R;

import java.util.ArrayList;

/**
 * Created by Kliven on 16/1/11.
 */
public class MessageAdapter extends FragmentPagerAdapter {

    private ArrayList<Fragment> fragments;
    private String[] titles = {"赞","通知","私信"};
    private Context context;

    public MessageAdapter(FragmentManager fm,ArrayList<Fragment> fragments,Context context) {
        super(fm);
        this.fragments = fragments;
        this.context = context;
    }

    @Override
    public Fragment getItem(int position) {
        return fragments.get(position);
    }

    @Override
    public int getCount() {
        return fragments.size();
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return titles[position];
    }
    public View getTabView(int postion) {
        View view = LayoutInflater.from(context).inflate(R.layout.item_msg_tablayout, null);

        TextView textView = (TextView) view.findViewById(R.id.tv_tab_text);

        textView.setText(titles[postion]);


        return view;
    }

}
